var db = require('../../core/database.js');
var fs = require('fs');
var conf = require('../../core/module.js');

function initModule (idModule) {
	console.log('-*-*-*- '+ idModule + '-*-*-*-');
}

function createModule (moduleName, params, callbackId) {

	db.createModule(moduleName, function (idModule) {
	
		db.insertAction('enocean_'+params.temperature.toString(), 'monitoring_temperature/temperature', idModule);

		var config = new conf.ConfigModule(moduleName);
		config.set (idModule, {'max_temperature': params.threshold});
		callbackId(idModule);
	});
}

function remove (params) {
	//TODO
}

var requirements = ["temperature"];

module.exports.init = initModule;
module.exports.create = createModule;
module.exports.remove = remove;
module.exports.requirements = requirements;
